# -*- coding: utf-8 -*-
from ctypes import cdll
import os
import time 
from MsgProcess import MsgProcess, MsgType

        
class DS18B20(MsgProcess):

	def Text(self, message):  
		t = cdll.LoadLibrary('plugin/DS18B20/ds.so')
		t.ds_init(3)#WiringPi
		dtlist=[]
		while True:
			#返回值：温度值 （-550~1250） 
			dt=t.main(3)#WiringPi
			if len(str(dt))<=4:
				dtlist.append(dt)

			if len(dtlist)>=3:
				dtlist.remove(max(dtlist))
				dtlist.remove(min(dtlist))

				self.say(str(dtlist[0]/10))
				self.say("摄氏度")
				break

			time.sleep(0.15)

		self.Stop()


